// stores/reviewStore.js
import { defineStore } from 'pinia'

export const useReviewStore = defineStore('reviews', {
  state: () => ({
    // 全部书评列表
    reviews: [],
   
  }),
  
  actions: {
    // 更新整个书评数据
    setReviews(payload) {
      this.reviews = payload.data || []
    },

    // 添加新书评
    addReview(newReview) {
      // 新书评插入到列表最前面
      this.reviews.unshift(newReview)
      // 更新最新书评
      this.latestReview = newReview
    }
  }
})